﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MG.HomeO2O.Model;
namespace MG.HomeO2O.DAL
{
    public class UsersDAL
    {
        EntityOP entity = new EntityOP();
        /// <summary>
        /// 登录信息 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public Users Login(string Uname, string Upwd)
        {
            return entity.Users.Where(p => (p.Uname == Uname) && (p.Upwd == Upwd)).FirstOrDefault();
          
        }
        /// <summary>
        /// 注册信息
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public int add(Users p)
        {
            entity.Users.Add(p);
            return entity.SaveChanges();
        }
        ///// <summary>
        ///// 用户名是否存在
        ///// </summary>
        ///// <param name="name"></param>
        ///// <returns></returns>
        //public int exit(string name)
        //{
        //    return Convert.ToInt32(entity.Users.SqlQuery("select count(*) from Users where Uname ='" + name + "'").ToList());
        //}
    }
}
